package fhq.hcmute.edu.vn.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import android.content.Context;
import android.media.MediaPlayer;

public final class ProjectUtil {
	public static final int ERROR = -1;
	public static final int NORMAL_MESSAGE = 0;
	public static final int BARCODE_SCAN_RESULT = 1;
	public static final int CONNECTION_ERROR = 2;
	public static final int CONNECTION_SUCCESSFULLY = 3;
	public static final int AUTHENTICATION = 4;
	public static final int AUTHENTICATION_REMEMBER = 5;
	public static final boolean YES = true;
	public static final boolean NO = false;

	public static final int REQUEST_CODE_PICK_LANGUAGE = 100;
	public static final int RESULT_CODE_PICK_LANGUAGE_CHANGE = 101;
	public static final int RESULT_CODE_PICK_LANGUAGE_NONE = 102;

	public static final int REQUEST_CODE_SEARCH_FILE = 300;
	public static final int RESULT_CODE_SEARCH_FILE = 301;

	public static final int REQUEST_CODE_SPECIFIC_TYPE = 200;
	public static final int RESULT_CODE_SPECIFIC_TYPE = 201;

	public static final int SCREEN_VERTICAL_UP = 90;
	public static final int SCREEN_VERTICAL_DOWN = 180;
	public static final int SCREEN_HORIZONTAL_LEFT = 0;
	public static final int SCREEN_HORIZONTAL_RIGHT = 270;

	public static final int UPSERCASE = 1;
	public static final int LOWERCASE = -1;

	public static final int REQUEST_CODE_WIFI_MANAGER = 1;
	public static final int RESULT_CODE_WIFI_MANAGER = 2;
	public static final String KEY_DIALOG_TITLE = "key_dialog_tile";
	public static final String KEY_DIALOG_MESSAGE = "key_dialog_message";
	public static final String KEY_OVERRIDE_FILE_DOWNLOAD_EXISTS =
			"KEY_OVERRIDE_FILE_DOWNLOAD_EXISTS";
	public static final String KEY_OVERRIDE_FILE_UPLOAD_EXISTS =
			"KEY_OVERRIDE_FILE_UPLOAD_EXISTS";
	public static final String KEY_DIALOG_NEGATIVE_BUTTON =
			"key_dialog_negative_button";
	public static final String KEY_DIALOG_POSITIVE_BUTTON =
			"key_dialog_positive_button";

	private ProjectUtil() {

	}

	public static final String SECRECT_KEY = "hien098@X";

	public static String md5(final String s) {
		try {
			MessageDigest m = MessageDigest.getInstance("MD5");
			m.update(s.getBytes(), 0, s.length());
			BigInteger i = new BigInteger(1, m.digest());
			return String.format("%1$032x", i);
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return null;
	}

	public static void playSound(final Context mContext, final int soundID) {
		MediaPlayer beepSound = MediaPlayer.create(mContext, soundID);
		beepSound.start();
	}
}
